﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ThreeByte.ActiveDeck.Config;
using ThreeByte.ActiveDeck.Content;
using ThreeByte.ActiveDeck.AddIn.Config;
using log4net;

namespace ThreeByte.ActiveDeck.Controls
{
    /// <summary>
    /// Interaction logic for ScoreReportConfiguration.xaml
    /// </summary>
    public partial class ScoreReportConfiguration : UserControl
    {
        private static readonly ILog log = LogManager.GetLogger(typeof(ScoreReportConfiguration));

        private ScoreReportConfig _config;
        public ScoreReportConfiguration(PageConfig config) {
            InitializeComponent();

            DataContext = config;
            _config = (ScoreReportConfig)config;
        }

        private void AddQuestion_Click(object sender, RoutedEventArgs e) {
            //Open a new PageChooserForm
            CoreConfig currentConfig = Globals.ThisAddIn.GetCurrentConfig();
            PageChooserControl pageChooser = new PageChooserControl(currentConfig);
            HostForm newDialog = new HostForm(pageChooser);
            if(newDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
                PageConfig selectedPage = pageChooser.SelectedPage;
                _config.Questions.Add(selectedPage);
            }
        }

        private void RemoveQuestion_Click(object sender, RoutedEventArgs e) {
            //Get the page and remove from the collection
            PageConfig pageToRemove = (PageConfig)(((Button)sender).Tag);
            _config.Questions.Remove(pageToRemove);
        }

        //private void AddLayer_Click(object sender, RoutedEventArgs e) {
        //    //Show the slide chooser
        //    CoreConfig currentConfig = Globals.ThisAddIn.GetCurrentConfig();
        //    SlideChooserControl slideChooser = new SlideChooserControl(currentConfig);
        //    HostForm newDialog = new HostForm(slideChooser);
        //    if(newDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
        //        Console.WriteLine("Chose a slide");

        //        //If a slide is chosen, capture all of the interactive elements and add to a new layer config

        //        //Create a new LayerConfig
        //        LayerConfig newLayer = new LayerConfig(slideChooser.SelectedSlide);
        //        newLayer.Refresh();

        //        DesignerSlideConfig config = (DesignerSlideConfig)DataContext;
        //        config.Layers.Add(newLayer);
        //    }
        //}

        //private void RemoveLayer_Click(object sender, RoutedEventArgs e) {
        //    //Grab the object and remove it from the collection
        //    LayerConfig layerToRemove = ((Button)sender).Tag as LayerConfig;
        //    DesignerSlideConfig config = (DesignerSlideConfig)DataContext;
        //    config.Layers.Remove(layerToRemove);
        //}

        //private void RefreshLayer_Click(object sender, RoutedEventArgs e) {
        //    //Grab the object and remove it from the collection
        //    LayerConfig layerToRefresh = ((Button)sender).Tag as LayerConfig;
        //    layerToRefresh.Refresh();
        //}

        //private void ChangeConditionLayer_Click(object sender, RoutedEventArgs e) {
        //    //Show the condition inspector
        //    CoreConfig currentConfig = Globals.ThisAddIn.GetCurrentConfig();
        //    ConditionInspectorControl newCondition = new ConditionInspectorControl(currentConfig);
        //    HostForm newDialog = new HostForm(newCondition);
        //    if(newDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
        //        LayerConfig layerToUpdate = ((Button)sender).Tag as LayerConfig;
        //        layerToUpdate.Condition = newCondition.Condition;
        //    }

        //}

    }
}
